﻿<Window x:Class="PubSubManager.PubSubManagerWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
      
        xmlns:xmpp="clr-namespace:System.Net.XMPP;assembly=xmpp"
        Title="PubSub List Manager" Height="400" Width="500" Loaded="Window_Loaded">
    <Window.Resources>
        <Style x:Key="TextEntryPriorToClick" TargetType="{x:Type TextBox}">
            <Setter Property="FontWeight" Value="ExtraLight"></Setter>
            <Setter Property="FontStyle" Value="Italic"></Setter>
        </Style>
        <Style x:Key="TextEntryAfterClick" TargetType="{x:Type TextBox}">
            <Setter Property="FontWeight" Value="Regular"></Setter>
            <Setter Property="FontStyle" Value="Normal"></Setter>
        </Style>
    </Window.Resources>

    <Grid x:Name="GridLayoutMain">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"></RowDefinition>
            <RowDefinition Height="*"></RowDefinition>
        </Grid.RowDefinitions>
        <!--<Grid.ColumnDefinitions>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="Auto"></ColumnDefinition>
            <ColumnDefinition Width="*"></ColumnDefinition>
        </Grid.ColumnDefinitions>-->

        <StackPanel Grid.Row="0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Button Grid.Column="0" Grid.Row="0" Style="{StaticResource {x:Static ToolBar.ButtonStyleKey}}" x:Name="ButtonConnect" HorizontalContentAlignment="Center"  VerticalContentAlignment="Center" Click="ButtonConnect_Click" >
                    <Border Width="32" Height="32">
                        <Border.Style>
                            <Style>
                                <Style.Triggers>
                                    <DataTrigger Binding="{Binding Ready}" Value="False">
                                        <Setter Property="Border.Background" Value="{DynamicResource disconnected}" />
                                    </DataTrigger>
                                    <DataTrigger Binding="{Binding Ready}" Value="True">
                                        <Setter Property="Border.Background" Value="{DynamicResource connected}" />
                                    </DataTrigger>
                                </Style.Triggers>
                            </Style>
                        </Border.Style>
                    </Border>
                </Button>
                <Label Grid.Column="1" Grid.Row="1" Margin="5,5,5,5" FontWeight="ExtraBold" FontSize="20" Content="Pub Sub List Manager" MouseDoubleClick="Label_MouseDoubleClick"  ></Label>
                <Label Grid.Column="1" Grid.Row="2" Margin="5,5,5,5" FontWeight="Regular" FontSize="14" Content="{Binding XMPPState}" ></Label>
            </Grid>

            <Grid Grid.Row="1" Grid.ColumnSpan="3">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"></RowDefinition>
                    <RowDefinition Height="*"></RowDefinition>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>

                <Grid Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                        <RowDefinition Height="*"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                        <RowDefinition Height="Auto"></RowDefinition>
                    </Grid.RowDefinitions>
                    <Grid Grid.Row="0">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"></ColumnDefinition>
                            <ColumnDefinition Width="Auto"></ColumnDefinition>
                        </Grid.ColumnDefinitions>
                        <TextBox HorizontalAlignment="Stretch" Grid.Column="0" Margin="3,3,3,3" Height="30" x:Name="TextBoxServerName" Text="{Binding Server}"  VerticalContentAlignment="Center"  Style="{StaticResource TextEntryPriorToClick}" MouseLeftButtonDown="TextBoxNewNodeName_MouseLeftButtonDown" TouchDown="TextBoxNewNodeName_TouchDown" TextChanged="TextBoxNewNodeName_TextChanged" ClipToBounds="False"></TextBox>
                        <Button Grid.Column="1" Margin="3,3,3,3" Width="Auto" Height="30" x:Name="ButtonQueryServer" Click="ButtonQueryServer_Click" ToolTip="Service discovery">
                            <Image Source="/PubSubManager;component/Images/refresh.png" ></Image>
                        </Button>
                    </Grid>

                    <ComboBox HorizontalAlignment="Stretch"  Margin="3,3,3,3" Height="30" Grid.Row="1" x:Name="ComboBoxRootNodes" ItemsSource="{Binding PubSubManager.PubSubDictionary.Keys}" SelectionChanged="ComboBoxRootNodes_SelectionChanged" >

                    </ComboBox>

                    <TreeView ItemsSource="{Binding PubSubDictionary}" Grid.Row="2"  Margin="3,3,3,3" SelectedItemChanged="TreeViewPubSubNodes_SelectedItemChanged" Name="TreeViewPubSubNodes" HorizontalAlignment="Stretch">
                        <TreeView.Resources>
                            <HierarchicalDataTemplate ItemsSource="{Binding Value}" DataType="{x:Type xmpp:item}">
                                <StackPanel>
                                    <TextBlock Text="{Binding Node}"></TextBlock>
                                    <TextBlock Text="{Binding Name}"></TextBlock>
                                    <TextBlock Text="{Binding JID}"></TextBlock>
                                </StackPanel>

                            </HierarchicalDataTemplate>
                        </TreeView.Resources>
                        <TreeView.ItemTemplate>
                            <HierarchicalDataTemplate ItemsSource="{Binding Value}">
                                <TextBlock Text="{Binding Key}"></TextBlock>
                                <HierarchicalDataTemplate.ItemTemplate>
                                    <DataTemplate>
                                        <StackPanel>
                                            <TextBlock Text="{Binding Name}"></TextBlock>
                                            <TextBlock Text="{Binding Node}"></TextBlock>
                                            <TextBlock Text="{Binding JID}"></TextBlock>
                                        </StackPanel>
                                    </DataTemplate>
                                </HierarchicalDataTemplate.ItemTemplate>
                            </HierarchicalDataTemplate>
                        </TreeView.ItemTemplate>
                    </TreeView>


                    <ListView ItemsSource="{Binding PubSubDictionary.Values}" Grid.Row="3" Margin="3,3,3,3" x:Name="ListViewPubSubItems">
                        <ListView.View>
                            <GridView>
                                <GridViewColumn Header="Node">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Node}"></TextBlock>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Name">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding Name}"></TextBlock>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                                <GridViewColumn Header="Created By">
                                    <GridViewColumn.CellTemplate>
                                        <DataTemplate>
                                            <TextBlock Text="{Binding JID}"></TextBlock>
                                        </DataTemplate>
                                    </GridViewColumn.CellTemplate>
                                </GridViewColumn>
                            </GridView>
                        </ListView.View>
                    </ListView>
                    <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Stretch">
                        <TextBox Margin="3,3,3,3"  Width="120" Height="30" HorizontalAlignment="Stretch" x:Name="TextBoxNewNodeName" Text="Enter node name"  VerticalContentAlignment="Center"  Style="{StaticResource TextEntryPriorToClick}" MouseLeftButtonDown="TextBoxNewNodeName_MouseLeftButtonDown" TouchDown="TextBoxNewNodeName_TouchDown" TextChanged="TextBoxNewNodeName_TextChanged"></TextBox>
                        <Button Margin="3,3,3,3" HorizontalAlignment="Right"  Height="30" x:Name="ButtonAddNode" Click="ButtonAddNode_Click" ToolTip="Add Node">
                            <Image Source="/PubSubManager;component/Images/add.png"></Image>
                        </Button>
                    </StackPanel>
                    <StackPanel Grid.Row="5" Orientation="Horizontal" HorizontalAlignment="Stretch">
                        <TextBox Margin="3,3,3,3" Height="30" Width="120" HorizontalAlignment="Stretch" x:Name="TextBoxNewItemName" Text="Enter item name"  VerticalContentAlignment="Center"  Style="{StaticResource TextEntryPriorToClick}" MouseLeftButtonDown="TextBoxNewItemName_MouseLeftButtonDown" TouchDown="TextBoxNewNodeName_TouchDown" TextChanged="TextBoxNewNodeName_TextChanged"></TextBox>
                        <Button Margin="3,3,3,3" HorizontalAlignment="Right"  Height="30" x:Name="ButtonAddItem" Click="ButtonAddItem_Click" ToolTip="Add item to selected node">
                            <Image Source="/PubSubManager;component/Images/add.png"></Image>
                        </Button>
                    </StackPanel>
                </Grid>


                <GridSplitter Margin="0,5,0,5" VerticalAlignment="Stretch" Grid.RowSpan="3" Grid.Column="1" Name="gridSplitter1" Width="10" HorizontalAlignment="Left">

                </GridSplitter>

                <TextBox Margin="5,5,5,5"   Grid.Row="1" Grid.Column="2" x:Name="TextBoxCode">

                </TextBox>
            </Grid>
        </StackPanel>
    </Grid>
</Window>
